package com.ruoyi.applet.appletUser.service.impl;

import com.ruoyi.applet.appletUser.domain.AppletUser;
import com.ruoyi.applet.appletUser.mapper.AppletUserMapper;
import com.ruoyi.applet.appletUser.service.IAppletUserService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 小程序用户Service业务层处理
 * @author ruoyi
 * @date 2024-11-19
 */
@Service
public class AppletUserServiceImpl implements IAppletUserService {
    
    @Resource
    private AppletUserMapper appletUserMapper;
    
    /**
     * 查询小程序用户
     * @param id 小程序用户主键
     * @return 小程序用户
     */
    @Override
    public AppletUser selectAppletUserById(Long id) {
        return appletUserMapper.selectAppletUserById(id);
    }
    
    /**
     * 查询小程序用户列表
     * @param appletUser 小程序用户
     * @return 小程序用户
     */
    @Override
    public List<AppletUser> selectAppletUserList(AppletUser appletUser) {
        return appletUserMapper.selectAppletUserList(appletUser);
    }
    
    /**
     * 新增小程序用户
     * @param appletUser 小程序用户
     * @return 结果
     */
    @Override
    public int insertAppletUser(AppletUser appletUser) {
        appletUser.setCreateTime(DateUtils.getNowDate());
        return appletUserMapper.insertAppletUser(appletUser);
    }
    
    /**
     * 修改小程序用户
     * @param appletUser 小程序用户
     * @return 结果
     */
    @Override
    public int updateAppletUser(AppletUser appletUser) {
        appletUser.setUpdateTime(DateUtils.getNowDate());
        return appletUserMapper.updateAppletUser(appletUser);
    }
    
    /**
     * 批量删除小程序用户
     * @param ids 需要删除的小程序用户主键
     * @return 结果
     */
    @Override
    public int deleteAppletUserByIds(String ids) {
        return appletUserMapper.deleteAppletUserByIds(Convert.toStrArray(ids));
    }
    
    /**
     * 删除小程序用户信息
     * @param id 小程序用户主键
     * @return 结果
     */
    @Override
    public int deleteAppletUserById(Long id) {
        return appletUserMapper.deleteAppletUserById(id);
    }
    
    
    /**
     * 根据用户openid获取用户信息
     * @param openid 微信唯一标识
     * @return {@link AppletUser}
     */
    @Override
    public AppletUser selectAppletUserByOpenid(String openid) {
        return appletUserMapper.selectAppletUserByOpenid(openid);
    }
}
